package com.yunji.order.service;

import cn.hutool.core.collection.CollUtil;
import com.google.common.collect.Lists;
import com.yunji.order.bo.GetOrderTradeBO;
import com.yunji.order.bo.TradeModifyAmountBO;
import com.yunji.order.bo.TradeModifyStatusBO;
import com.yunji.order.context.convert.TradeConvert;
import com.yunji.order.dao.ITradeDao;
import com.yunji.order.domain.TradeDO;
import com.yunji.order.dto.TradeParam;
import com.yunji.order.vo.TradeVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Project: yunji-coffee
 * @Package: com.yunji.order.service.impl
 * @Title: TradeServiceImpl
 * @Description: 支付订单接口实现
 * <p>
 * History:
 * Date                     Version     Author          Summary
 * ============================================================
 * 2024-04-10 14:19:02      V1.0        HuaAo       新建类
 */

@Service
public class TradeService {
    @Resource
    private ITradeDao tradeDao;

    public TradeDO selectTrade(String tradeCode) {
        return tradeDao.getByTradeCode(tradeCode);
    }

    public boolean createTrade(TradeDO trade) {
        return tradeDao.save(trade);
    }

    public boolean createTrades(List<TradeDO> trades) {
        return tradeDao.saveBatch(trades);
    }

    public List<TradeVO> tradeList(TradeParam p) {
        List<TradeDO> tradeDOS = tradeDao.tradeList(p);
        return TradeConvert.domain2VOS(tradeDOS);
    }

    public boolean updateTrade(TradeDO trade) {
        return tradeDao.updateById(trade);
    }

//    public boolean updateTradeStatus(TradeModifyStatusBO bo) {
//        return tradeDao.updateTrade(bo);
//    }

//    public boolean updateTradeAmount(TradeModifyAmountBO bo) {
//        return tradeDao.updateTrade(bo);
//    }

    public boolean existsTrade(GetOrderTradeBO getOrderTradeBO) {
        return tradeDao.existsTrade((getOrderTradeBO));
    }

    public TradeDO getTrade(GetOrderTradeBO bo) {
        return tradeDao.getTrade(bo);
    }

    public List<TradeDO> listByTranNo(String transactionNo) {
        return tradeDao.listByTranNo(transactionNo);
    }
}
